//
//  CZTableViewCell.m
//  题1
//
//  Created by iOS001 on 15/12/12.
//  Copyright © 2015年 iOS001. All rights reserved.
//

#import "FDTableViewCellView.h"
#import "FDCellModel.h"
#import <Masonry.h>




@interface FDTableViewCellView ()

@property(nonatomic,strong)UILabel *label;

@end

@implementation FDTableViewCellView


-(UILabel *)label{
    
    if (_label==nil) {
        
        _label=[[UILabel alloc]init];
        CGFloat cellWidth=70;
        CGFloat cellHeight=30;
        _label.frame=CGRectMake(self.frame.size.width-cellWidth*0.5, (self.frame.size.height-cellHeight)*0.5, cellWidth, cellHeight);
        _label.textAlignment=NSTextAlignmentCenter;
        
        _label.backgroundColor=[[UIColor alloc]initWithRed:58.0/255.0 green:198.0/255.0 blue:197.0/255.0 alpha:1.0];
        _label.layer.cornerRadius=5;
        _label.layer.masksToBounds=YES;
    
    }
    return _label;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    self.selectionStyle=UITableViewCellSelectionStyleNone;
    
    return self;
}

-(void)setModel:(FDCellModel *)model{

    _model = model;
    
    //给标签赋值
    
    [self.contentView addSubview:self.label];
    
    [self.label mas_makeConstraints:^(MASConstraintMaker *make) {
        
        
        make.right.mas_equalTo(self.contentView.mas_right).offset(-1.5*ten);
        make.centerY.mas_offset(0);
        make.width.mas_equalTo(7*ten);
        make.height.mas_equalTo(3*ten);
    }];
    
    //判断状态设置label.text的颜色
    if (_model.isClick) {
        self.textLabel.textColor = [UIColor lightGrayColor];
        self.label.text=@"已订阅";
        self.label.textColor=[UIColor redColor];
    }else{
        
        self.textLabel.textColor = [UIColor blackColor];
        self.label.text=@"订阅";
        self.label.textColor=[UIColor whiteColor];
    }
    
    
}

@end
